<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .laytp-container .layui-table-header {height: 70px;}
    .layui-table-fixed-l .layui-table-body{width: auto !important;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="enginname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('人材机分包成本分析');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cheng_rcj_tong),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);


                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type:'numbers',title:'序号',totalRowText: '合计',fixed:'left',rowspan:2}
                ,{field:'name',title:'项目名称',fixed:'left',rowspan:2,templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.id+'\')">'+d.name+'</span>';
                    }}
                ,{field: '', title: '材料费(元)',colspan:4,align:'center'}
                ,{field: '', title: '人工费(元)',colspan:5,align:'center'}
                ,{field: '', title: '租赁费(元)',colspan:4,align:'center'}
                ,{field: '', title: '分包费(元)',colspan:4,align:'center'}
                ,{field: '', title: '措施费(元)',colspan:2,align:'center'}
            ],[
                {field: 'cai_con', title: '合同金额(元)',totalRow: true,align:'right',event: 'contract_cai1',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cai_con)+'</span>';
                    }}
                ,{field: 'cai_stuffru', title: '入库金额(元)',totalRow: true,align:'right',event: 'stuff_ru',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cai_stuffru)+'</span>';
                    }}
                ,{field: 'cai_stuffjie', title: '结算单金额(元)',totalRow: true,align:'right',event: 'stuff_jie',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cai_stuffjie)+'</span>';
                    }}
                ,{field: 'cai_fuku', title: '付款单(元)',totalRow: true,align:'right',event: 'payment_engin1',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cai_fuku)+'</span>';
                    }}

                ,{field: 'ren_con', title: '合同金额(元)',totalRow: true,align:'right',event: 'contract_cai2',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.ren_con)+'</span>';
                    }}
                ,{field: 'ren_labourshen', title: '进度款申报(元)',totalRow: true,align:'right',event: 'labour_shen',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.ren_labourshen)+'</span>';
                    }}
                ,{field: 'ren_labourjie', title: '完工结算金额(元)',totalRow: true,align:'right',event: 'labour_jie',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.ren_labourjie)+'</span>';
                    }}
                ,{field: 'ren_labourling', title: '零星劳务(元)',totalRow: true,align:'right',event: 'labour_ling',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.ren_labourling)+'</span>';
                    }}
                ,{field: 'ren_fuku', title: '付款单(元)',totalRow: true,align:'right',event: 'payment_engin2',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.ren_fuku)+'</span>';
                    }}

                ,{field: 'zu_con', title: '合同金额(元)',totalRow: true,align:'right',event: 'contract_cai3',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.zu_con)+'</span>';
                    }}
                ,{field: 'zu_devicejie', title: '结算单金额(元)',totalRow: true,align:'right',event: 'device_jie',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.zu_devicejie)+'</span>';
                    }}
                ,{field: 'zu_devicelin', title: '临时机械费(元)',totalRow: true,align:'right',event: 'device_lin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.zu_devicelin)+'</span>';
                    }}
                ,{field: 'zu_fuku', title: '付款单(元)',totalRow: true,align:'right',event: 'payment_engin3',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.zu_fuku)+'</span>';
                    }}

                ,{field: 'fen_con', title: '合同金额(元)',totalRow: true,align:'right',event: 'contract_cai4',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.fen_con)+'</span>';
                    }}
                ,{field: 'fen_subbaoshen', title: '进度款申报金额(元)',totalRow: true,align:'right',event: 'subbao_shen',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.fen_subbaoshen)+'</span>';
                    }}
                ,{field: 'fen_subbaojie', title: '完工结算金额(元)',totalRow: true,align:'right',event: 'subbao_jie',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.fen_subbaojie)+'</span>';
                    }}
                ,{field: 'fen_fuku', title: '付款单(元)',totalRow: true,align:'right',event: 'payment_engin4',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.fen_fuku)+'</span>';
                    }}
                ,{field: 'cuo_fuku', title: '付款单(元)',totalRow: true,align:'right',event: 'payment_engin5',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.cuo_fuku)+'</span>';
                    }}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){

                            if(currButAuth[key].butname == 'editout'){
                                continue;
                            }

                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'contract_cai1'){
                openPage('../contract_cai/tong.php?enginname='+encodeURI(data.name)+'&status=1&caihetype=1', '80%', '80%');
            }
            if(obj.event === 'stuff_ru'){
                openPage('../stuff_ru/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'stuff_jie'){
                openPage('../stuff_jie/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_engin1'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=1', '80%', '80%');
            }


            if(obj.event === 'contract_cai2'){
                openPage('../contract_cai/tong.php?enginname='+encodeURI(data.name)+'&status=1&caihetype=2', '80%', '80%');
            }
            if(obj.event === 'labour_shen'){
                openPage('../labour_shen/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'labour_jie'){
                openPage('../stuff_jie/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'labour_ling'){
                openPage('../stuff_jie/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_engin2'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=2', '80%', '80%');
            }

            if(obj.event === 'contract_cai3'){
                openPage('../contract_cai/tong.php?enginname='+encodeURI(data.name)+'&status=1&caihetype=3', '80%', '80%');
            }
            if(obj.event === 'device_jie'){
                openPage('../device_jie/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'device_lin'){
                openPage('../device_lin/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_engin3'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=3', '80%', '80%');
            }


            if(obj.event === 'contract_cai4'){
                openPage('../contract_cai/tong.php?enginname='+encodeURI(data.name)+'&status=1&caihetype=4', '80%', '80%');
            }
            if(obj.event === 'subbao_shen'){
                openPage('../subbao_shen/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'subbao_jie'){
                openPage('../device_lin/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_engin4'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=4', '80%', '80%');
            }

            if(obj.event === 'payment_engin5'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budid=5', '80%', '80%');
            }
        });

        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id);
    }



</script>
</body>
</html>
